﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 基于WPF的电缆采样数据分析系统.Models;
using 基于WPF的电缆采样数据分析系统.Tools.LangugeTool;

namespace 基于WPF的电缆采样数据分析系统.ViewModels
{
    public class SettingsUCViewModel : BindableBase
    {

        #region 左侧菜单栏数据

        /// <summary>
        /// 左侧菜单栏数据
        /// </summary>
        private List<LeftMenuInfo> _LeftMenuInfoList;

        /// <summary>
        /// 左侧菜单栏数据
        /// </summary>
        public List<LeftMenuInfo> LeftMenuInfoList
        {
            get { return _LeftMenuInfoList; }
            set
            {
                _LeftMenuInfoList = value;
                RaisePropertyChanged();
            }
        }

        #endregion


        #region 设置页面切换导航
        /// <summary>
        /// 设置页面切换导航命令
        /// </summary>
        public DelegateCommand<LeftMenuInfo> SetContentRegionCmm { get; set; }

        /// <summary>
        /// 区域管理
        /// </summary>
        private readonly IRegionManager RegionManager;

        /// <summary>
        /// 设置页面切换导航
        /// </summary>
        /// <param name="leftMenuInfo"></param>
        private void SetContentRegionFun(LeftMenuInfo leftMenuInfo)
        {
            if (leftMenuInfo == null || string.IsNullOrEmpty(leftMenuInfo.ViewName))
            {
                return;
            }

            RegionManager.Regions["SetContentRegion"].RequestNavigate(leftMenuInfo.ViewName);
        }


        #endregion

        /// <summary>
        /// 构造器
        /// </summary>
        public SettingsUCViewModel(IRegionManager _RegionManager)
        {
            // 菜单数据初始化
            CreateList();

            // 绑定设置页面切换导航命令
            SetContentRegionCmm = new DelegateCommand<LeftMenuInfo>(SetContentRegionFun);

            // 绑定区域管理
            RegionManager = _RegionManager;
        }


        /// <summary>
        /// 菜单数据初始化
        /// </summary>
        private void CreateList()
        {
            // 左侧菜单数据初始化
            LeftMenuInfoList = new List<LeftMenuInfo>();
            LeftMenuInfoList.Add(new LeftMenuInfo() { Icon = "Paletee", MenuName = LangugeConvertor.GetValue("Individuation"), ViewName = "PersonalUC" });
            LeftMenuInfoList.Add(new LeftMenuInfo() { Icon = "Cog", MenuName = LangugeConvertor.GetValue("SystemSetting"), ViewName = "SysSetUC" });
            LeftMenuInfoList.Add(new LeftMenuInfo() { Icon = "Information", MenuName = LangugeConvertor.GetValue("AboutMore"), ViewName = "AboutUsUC" });
        }

    }
}
